package com.backend.securitiessystem.controller;

import com.backend.securitiessystem.dto.RiseFallDto;
import com.backend.securitiessystem.pojo.RiseFall;
import com.backend.securitiessystem.result.Result;
import com.backend.securitiessystem.service.RiseFallService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 资金流涨跌 controller
 *
 * @author qksuki
 * @date 2024-05-21 03:42:56
 */
@RestController
@Slf4j
public class RiseFallController {

    @Resource
    private RiseFallService riseFallService;

    @GetMapping("/getUpAndDownsByPage")
    public Result<IPage<RiseFallDto>> getRiseFallByPage(
            @RequestParam(defaultValue = "2") Integer pageNum,
            @RequestParam(defaultValue = "2") Integer pageSize
    ) {

        QueryWrapper<RiseFall> queryWrapper=new QueryWrapper<>();

        IPage<RiseFallDto> riseFallDtoIPage= riseFallService
                .selectPageWithCondition(pageNum,pageSize,queryWrapper);

        log.info("获取资金流涨跌分页数据: {}", riseFallDtoIPage);
        return Result.success(riseFallDtoIPage);
    }
}
